﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="../internal.js"></script>
    <style type="text/css">

        * {
            margin: 0;
            padding: 0;
            color: #838383;
        }

        table {
            font-size: 12px;
            margin: 10px;
            line-height: 30px;
        }

        .txt {
            width: 300px;
            height: 21px;
            line-height: 21px;
            border: 1px solid #d7d7d7;
        }
       
    </style>
</head>
<body>

    <table>
        <tr>
            <td><label for="href">音频地址：</label></td>
            <td><input class="txt" id="href" type="text" /></td>
        </tr>
    </table>
    <script type="text/javascript">
    function handleDialogOk() {
        if ($G('href').value) {
            var patt1 = /ogg|oga|aac|m4a|mp3|wav/gi;

            if (patt1.test($G('href').value)) {
                editor.execCommand('insertHtml', '<div class="audioplayer"><audio controls ' +
                    'preload="auto"><source src="' + $G('href').value + '" ></audio>' +
                    '</div>');
                dialog.close();

            } else {
                alert("不支持该音频格式");
                return false;
            }

        } else {
            alert("请输入音频地址");
            return false;
        }
    }
    dialog.onok = handleDialogOk;
    $G('href').onkeydown = function(evt) {
        evt = evt || window.event;
        if (evt.keyCode == 13) {
            handleDialogOk();
            return false;
        }
    }
    </script>
</body>
</html>